***************************************
**** Table A14: Effects of Priming 	****
***************************************

use "$dir/Data/analysis_main.dta", clear


*** Panel A (pooled)

eststo clear

cap drop gotfin_first postsal_first gotcashpoorfin_first postcashpoorsal_first 
cap drop gotfin_later postsal_later gotcashpoorfin_later postcashpoorsal_later
gen gotfin_first = gotfin_hr1
gen postsal_first = postsal_hr1
gen gotcashpoorfin_first = gotcashpoorfin_hr1
gen postcashpoorsal_first = postcashpoorsal_hr1

gen gotfin_later = gotfin_hr2p
gen postsal_later = postsal_hr2p
gen gotcashpoorfin_later = gotcashpoorfin_hr2p
gen postcashpoorsal_later = postcashpoorsal_hr2p


eststo: reghdfe n_productivity gotfin_first postsal_first gotcashpoorfin_first postcashpoorsal_first gotfin_later postsal_later gotcashpoorfin_later postcashpoorsal_later cash_postpay cash_announce blhrprod blhrprodsq blhrprod_miss bs_labor_30_miss future_fin_worry_miss i.pd if pd>0, vce(cl pid) absorb(roundgroup)
estadd local first "1 hour"


	cap drop *_hiw
	foreach y of varlist gotfin_first postsal_first gotcashpoorfin_first postcashpoorsal_first gotfin_later postsal_later gotcashpoorfin_later postcashpoorsal_later cash_postpay cash_announce {
		gen `y'_hiw = wealth_hi_avg*`y'
	}
	eststo: reghdfe n_productivity gotfin_first postsal_first gotcashpoorfin_first postcashpoorsal_first gotfin_later postsal_later gotcashpoorfin_later postcashpoorsal_later cash_postpay cash_announce *_hiw wealth_hi_avg blhrprod blhrprodsq blhrprod_miss bs_labor_30_miss future_fin_worry_miss i.pd if pd>0, vce(cl pid) absorb(roundgroup)
	estadd local first "1 hour"
	estadd local interac "Lower strain"

	
cap drop gotfin_first postsal_first gotcashpoorfin_first postcashpoorsal_first gotfin_later postsal_later gotcashpoorfin_later postcashpoorsal_later
gen gotfin_first = gotfin_hr1_2
gen postsal_first = postsal_hr1_2
gen gotcashpoorfin_first = gotcashpoorfin_hr1_2
gen postcashpoorsal_first = postcashpoorsal_hr1_2

gen gotfin_later = gotfin_hr3p
gen postsal_later = postsal_hr3p
gen gotcashpoorfin_later = gotcashpoorfin_hr3p
gen postcashpoorsal_later = postcashpoorsal_hr3p

eststo: reghdfe n_productivity gotfin_first postsal_first gotcashpoorfin_first postcashpoorsal_first gotfin_later postsal_later gotcashpoorfin_later postcashpoorsal_later cash_postpay cash_announce blhrprod blhrprodsq blhrprod_miss bs_labor_30_miss future_fin_worry_miss i.pd if pd>0, vce(cl pid) absorb(roundgroup)
estadd local first "2 hours"


	cap drop *_hiw
	foreach y of varlist gotfin_first postsal_first gotcashpoorfin_first postcashpoorsal_first gotfin_later postsal_later gotcashpoorfin_later postcashpoorsal_later cash_postpay cash_announce {
		gen `y'_hiw = wealth_hi_avg*`y'
	}
	eststo: reghdfe n_productivity gotfin_first postsal_first gotcashpoorfin_first postcashpoorsal_first gotfin_later postsal_later gotcashpoorfin_later postcashpoorsal_later cash_postpay cash_announce *_hiw wealth_hi_avg blhrprod blhrprodsq blhrprod_miss bs_labor_30_miss future_fin_worry_miss i.pd if pd>0, vce(cl pid) absorb(roundgroup)
	estadd local first "2 hours"
	estadd local interac "Lower strain"
	

cap drop gotfin_first postsal_first gotcashpoorfin_first postcashpoorsal_first 
gen gotfin_first = gotfin
gen postsal_first = postsal
gen gotcashpoorfin_first = gotcashpoorfin
gen postcashpoorsal_first = postcashpoorsal

eststo: reghdfe n_productivity gotfin_first postsal_first gotcashpoorfin_first postcashpoorsal_first cash_postpay cash_announce blhrprod blhrprodsq blhrprod_miss bs_labor_30_miss future_fin_worry_miss i.pd if pd>0, vce(cl pid) absorb(roundgroup)

	cap drop *_hiw
	foreach y of varlist gotfin_first postsal_first gotcashpoorfin_first postcashpoorsal_first cash_postpay cash_announce{
		gen `y'_hiw = wealth_hi_avg*`y'
	}
	
eststo: reghdfe n_productivity gotfin_first postsal_first gotcashpoorfin_first postcashpoorsal_first cash_postpay cash_announce *_hiw wealth_hi_avg blhrprod blhrprodsq blhrprod_miss bs_labor_30_miss future_fin_worry_miss i.pd if pd>0, vce(cl pid) absorb(roundgroup)

gen gotfin_later_hiw=.
gen gotcashpoorfin_later_hiw=.

label var gotfin_first "Post-priming"
label var gotcashpoorfin_first "Post-priming $\times$ Pre-pay"
label var gotfin_later "Pp later hrs"
label var gotcashpoorfin_later "Pp later hrs $\times$ Pre-pay"

label var gotfin_first_hiw "Post-priming $\times$ Higher wealth"
label var gotcashpoorfin_first_hiw "Post-priming $\times$ Pre-pay $\times$ Higher wealth"
label var gotfin_later_hiw "Pp later hrs $\times$ Higher wealth"
label var gotcashpoorfin_later_hiw "Pp later hours $\times$ Pre-pay $\times$ Higher wealth"


#delimit ;
local tablerow gotfin_first gotcashpoorfin_first gotfin_first_hiw gotcashpoorfin_first_hiw ;  // gotfin_later gotcashpoorfin_later gotfin_later_hiw gotcashpoorfin_later_hiw

esttab using "$oa/$t/Table_A14_A.tex", 
	b(3) se booktabs star(* .1 ** .05 *** .01) nonotes nomtitles nonumbers 
	replace label style(tex) gaps keep(`tablerow') order(`tablerow') 
	stats(N, labels("N: worker-hours") fmt(%9.0fc)) 
	prehead("{\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} \begin{tabular}
	{@{\extracolsep{6pt}}p{9.5cm}*{15}{>{\centering\arraybackslash}m{1.9cm}}@{}} 
	\toprule      
		&\multicolumn{6}{c}{\textbf{Hourly Production}}      \bigstrut       \\ 
		\cline{2-7}  \addlinespace  
		 &\multicolumn{2}{c}{First hour after priming}  &\multicolumn{2}{c}{Two hours after priming} &\multicolumn{2}{c}{All hours after priming}
		 \bigstrut       \\                 
		 \cline{2-3} \cline{4-5} \cline{6-7} \addlinespace 
		& (1) & (2) & (3) & (4)  & (5) & (6)   \\
		\midrule \addlinespace 
		\multicolumn{6}{l}{\textbf{PANEL A: Overall priming impacts}}      
		\bigstrut          \\ ") ;		 
#delimit cr	




*** Panel B (Day 10-11 priming)

eststo clear

cap drop gotfin_first postsal_first gotcashpoorfin_first postcashpoorsal_first 
cap drop gotfin_later postsal_later gotcashpoorfin_later postcashpoorsal_later
cap drop gotfin_first_t1 postsal_first_t1 gotfin_later_t1 postsal_later_t1

gen gotfin_first = gotfin_hr1_t2
gen postsal_first = postsal_hr1_t2
gen gotcashpoorfin_first = gotcashpoorfin_hr1_t2
gen postcashpoorsal_first = postcashpoorsal_hr1_t2

gen gotfin_later = gotfin_hr2p_t2
gen postsal_later = postsal_hr2p_t2
gen gotcashpoorfin_later = gotcashpoorfin_hr2p_t2
gen postcashpoorsal_later = postcashpoorsal_hr2p_t2

gen gotfin_first_t1 = gotfin_hr1_t1
gen postsal_first_t1 = postsal_hr1_t1
gen gotfin_later_t1 = gotfin_hr2p_t1
gen postsal_later_t1 = postsal_hr2p_t1


eststo: reghdfe n_productivity gotfin_first postsal_first gotcashpoorfin_first postcashpoorsal_first gotfin_later postsal_later gotcashpoorfin_later postcashpoorsal_later gotfin_first_t1 postsal_first_t1 gotfin_later_t1 postsal_later_t1 cash_postpay cash_announce blhrprod blhrprodsq blhrprod_miss bs_labor_30_miss future_fin_worry_miss i.pd if pd>0, vce(cl pid) absorb(roundgroup)
estadd local first "1 hour"


	cap drop *_hiw
	foreach y of varlist gotfin_first postsal_first gotcashpoorfin_first postcashpoorsal_first gotfin_later postsal_later gotcashpoorfin_later postcashpoorsal_later gotfin_first_t1 postsal_first_t1 gotfin_later_t1 postsal_later_t1 cash_postpay cash_announce{
		gen `y'_hiw = wealth_hi_avg*`y'
	}
	eststo: reghdfe n_productivity gotfin_first postsal_first gotcashpoorfin_first postcashpoorsal_first gotfin_later postsal_later gotcashpoorfin_later postcashpoorsal_later gotfin_first_t1 postsal_first_t1 gotfin_later_t1 postsal_later_t1 *_hiw wealth_hi_avg cash_postpay cash_announce blhrprod blhrprodsq blhrprod_miss bs_labor_30_miss future_fin_worry_miss i.pd if pd>0, vce(cl pid) absorb(roundgroup)
	estadd local first "1 hour"
	estadd local interac "Lower strain"

	
cap drop gotfin_first postsal_first gotcashpoorfin_first postcashpoorsal_first gotfin_later postsal_later gotcashpoorfin_later postcashpoorsal_later gotfin_first_t1 postsal_first_t1 gotfin_later_t1 postsal_later_t1
gen gotfin_first = gotfin_hr1_2_t2
gen postsal_first = postsal_hr1_2_t2
gen gotcashpoorfin_first = gotcashpoorfin_hr1_2_t2
gen postcashpoorsal_first = postcashpoorsal_hr1_2_t2

gen gotfin_later = gotfin_hr3p_t2
gen postsal_later = postsal_hr3p_t2
gen gotcashpoorfin_later = gotcashpoorfin_hr3p_t2
gen postcashpoorsal_later = postcashpoorsal_hr3p_t2

gen gotfin_first_t1 = gotfin_hr2_t1
gen postsal_first_t1 = postsal_hr2_t1
gen gotfin_later_t1 = gotfin_hr3p_t1
gen postsal_later_t1 = postsal_hr3p_t1


eststo: reghdfe n_productivity gotfin_first postsal_first gotcashpoorfin_first postcashpoorsal_first gotfin_later postsal_later gotcashpoorfin_later postcashpoorsal_later gotfin_first_t1 postsal_first_t1 gotfin_later_t1 postsal_later_t1 cash_postpay cash_announce blhrprod blhrprodsq blhrprod_miss bs_labor_30_miss future_fin_worry_miss i.pd if pd>0, vce(cl pid) absorb(roundgroup)
estadd local first "2 hours"


	cap drop *_hiw
	foreach y of varlist gotfin_first postsal_first gotcashpoorfin_first postcashpoorsal_first gotfin_later postsal_later gotcashpoorfin_later postcashpoorsal_later gotfin_first_t1 postsal_first_t1 gotfin_later_t1 postsal_later_t1 cash_postpay cash_announce{
		gen `y'_hiw = wealth_hi_avg*`y'
	}
	eststo: reghdfe n_productivity gotfin_first postsal_first gotcashpoorfin_first postcashpoorsal_first gotfin_later postsal_later gotcashpoorfin_later postcashpoorsal_later gotfin_first_t1 postsal_first_t1 gotfin_later_t1 postsal_later_t1 *_hiw wealth_hi_avg cash_postpay cash_announce blhrprod blhrprodsq blhrprod_miss bs_labor_30_miss future_fin_worry_miss i.pd if pd>0, vce(cl pid) absorb(roundgroup)
	estadd local first "2 hours"
	estadd local interac "Lower strain"
	

cap drop gotfin_first postsal_first gotcashpoorfin_first postcashpoorsal_first gotfin_first_t1 postsal_first_t1 
gen gotfin_first = gotfin_t2
gen postsal_first = postsal_t2
gen gotcashpoorfin_first = gotcashpoorfin_t2
gen postcashpoorsal_first = postcashpoorsal_t2
gen gotfin_first_t1 = gotfin_t1
gen postsal_first_t1 = postsal_t1


eststo: reghdfe n_productivity gotfin_first postsal_first gotcashpoorfin_first postcashpoorsal_first gotfin_first_t1 postsal_first_t1 cash_postpay cash_announce blhrprod blhrprodsq blhrprod_miss  bs_labor_30_miss future_fin_worry_miss i.pd if pd>0, vce(cl pid) absorb(roundgroup)

	cap drop *_hiw
	foreach y of varlist gotfin_first postsal_first gotcashpoorfin_first postcashpoorsal_first gotfin_first_t1 postsal_first_t1 cash_postpay cash_announce{
		gen `y'_hiw = wealth_hi_avg*`y'
	}
	
eststo: reghdfe n_productivity gotfin_first postsal_first gotcashpoorfin_first postcashpoorsal_first gotfin_first_t1 postsal_first_t1 *_hiw wealth_hi_avg cash_postpay cash_announce blhrprod blhrprodsq blhrprod_miss bs_labor_30_miss future_fin_worry_miss i.pd if pd>0, vce(cl pid) absorb(roundgroup)

gen gotfin_later_hiw=.
gen gotcashpoorfin_later_hiw=.

label var gotfin_first "Post-priming (Day 10-11)"
label var gotcashpoorfin_first "Post-priming (Day 10-11) $\times$ Pre-pay"
label var gotfin_later "Pp later hrs (Day 10-11)"
label var gotcashpoorfin_later "Pp later hrs (Day 10-11) $\times$ Pre-pay"

label var gotfin_first_hiw "Post-priming (Day 10-11) $\times$ Higher wealth"
label var gotcashpoorfin_first_hiw "Post-priming (Day 10-11) $\times$ Pre-pay $\times$ Higher wealth"
label var gotfin_later_hiw "Pp later hrs (Day 10-11) $\times$ Higher wealth"
label var gotcashpoorfin_later_hiw "Pp later hours (Day 10-11) $\times$ Pre-pay $\times$ Higher wealth"

label var gotfin_first_t1 "Post-priming (Day 6-7)"
label var gotfin_first_t1_hiw "Post-priming (Day 6-7) $\times$ Higher wealth"
label var gotfin_later_t1 "Pp later hrs (Day 6-7)"

#delimit ;
local tablerow gotfin_first gotcashpoorfin_first gotfin_first_t1 gotfin_first_hiw gotcashpoorfin_first_hiw gotfin_first_t1_hiw  ;  // gotfin_later gotcashpoorfin_later gotfin_later_hiw gotcashpoorfin_later_hiw

esttab using "$oa/$t/Table_A14_B.tex", 
	b(3) se booktabs star(* .1 ** .05 *** .01) nonotes nomtitles nonumbers
	replace label style(tex) gaps keep(`tablerow') order(`tablerow') 
	stats(N, labels("N: worker-hours") fmt(%9.0fc)) 
	prehead("{\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} \begin{tabular}
	{@{\extracolsep{6pt}}p{9.5cm}*{15}{>{\centering\arraybackslash}m{1.9cm}}@{}} 
	\toprule      
		\multicolumn{6}{l}{\textbf{PANEL B: Priming impacts before and after interim payment}}      
		\bigstrut          \\ ") ;		 
#delimit cr	


